<%@ page import="com.zhf.demo01.Person" %><%--
  Created by IntelliJ IDEA.
  User: win
  Date: 2020/10/18
  Time: 14:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>实现Bean对象中属性的获取和打印</title>
</head>
<body>
<%--JSP语法规则中原始方式实现对象的创建和输出--%>
<%
    Person person = new Person("zhangfei", 30);
    pageContext.setAttribute("person",person);
    pageContext.setAttribute("var","name");
%>
<%="获取到的姓名为："+person.getName()%><br>
<%="获取到的年龄为："+person.getAge()%><br>
<%--使用EL表达式获取属性--%>
获取到的姓名是：${person.name}<br>
获取到的年龄是：${person.age}<br>
${person["name"]}<br>
${person["age"]}<br>
<%--测试动态取值--%>
动态取值的结果为：${person[var]}
</body>
</html>
